from django.utils.deprecation import MiddlewareMixin


class AccessCorsMiddleware(MiddlewareMixin):

    def process_response(self, request, response):
        # 处理简单请求跨域
        response['Access-Control-Allow-Origin'] = "*"
        if request.method == 'OPTIONS':
            response['Access-Control-Request-Headers'] = 'content-type'
            response['Access-Control-Request-Method'] = 'post'

        return response
